package easybooking;

import easybooking.db.AirlineMapper;
import easybooking.db.AirportMapper;
import easybooking.db.BookingMapper;
import easybooking.db.CustomerMapper;
import easybooking.db.FlightMapper;
import easybooking.db.PlaneMapper;
import easybooking.db.SeatMapper;
import easybooking.db.TypeMapper;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.ArrayList; 

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.8349C54C-FA1D-4335-3668-02697FAF837C]
// </editor-fold> 
public class FlightServer {

//    // <editor-fold defaultstate="collapsed" desc=" UML Marker ">
//    // #[regen=yes,id=DCE.398FF0FF-A04D-A64F-0B79-65562F5AFF23]
//    // </editor-fold>
//    private FlightManagement Management = null;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A5917095-422F-E224-EC9C-DAF890AE9DBE]
    // </editor-fold> 
    private FlightManagement management;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.D9A9DFE7-6621-92DA-D247-F3A574327BF8]
    // </editor-fold> 
    public FlightServer () {
		try {
                      
					/*
			 * Für die Bank benötigen wir eine Verwaltung. In dieser werden wichtige
			 * Aktivitäten vorgehalten.
			 *
			 * Die Verwaltung muß wissen, für welche Bank sie arbeitet und welche
			 * Mapper zur Verfügung stehen, um Daten in die Datenbank zu transportieren
			 * zu können.
			 */
			management = new FlightManagementImpl(BookingMapper.bookingMapper(), FlightMapper.flightMapper(), CustomerMapper.customerMapper(),AirportMapper.airportMapper() , PlaneMapper.planeMapper(), AirlineMapper.airlineMapper(), TypeMapper.typeMapper(), SeatMapper.seatMapper());

//			 Wir melden das Verwaltungsobjekt bei einer RMI-Registry an.
                        Registry registry = LocateRegistry.createRegistry(1099);
			Naming.rebind("rmi://localhost:1099/FlightManagement1",management);

//                        Naming.rebind("rmi://HakanKeles-PC:1099/FlightManagement1", management);
//
//
		System.out.println("FlightServer in Registry eingetragen...");
		}
		catch (RemoteException e) {
			e.printStackTrace();
		}
		catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
    

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.6D6BBC78-3794-410E-230B-8045BF6EC7CF]
    // </editor-fold> 
    public static void main(String args[]) {
		FlightServer server = new FlightServer();
		System.out.println("Server gestartet...");
	}

    /**
     * Gets the flight management object.
     * @return the Flight Management object
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.2BD77E47-FB28-47B6-82F9-41EAFB6F0E0A]
    // </editor-fold> 
    public FlightManagement getManagement () {
        return management;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,regenBody=yes,id=DCE.CC6BFE11-B692-6C7A-75B3-1EA9AD637F0F]
    // </editor-fold> 
    public void setManagement (FlightManagement val) {
        this.management = val;
    }

}

